<?php
/**
 * Filter and validators for forms
 *
 * @author     Mario Schillermann <info@rockit-flash.com>
 * @encoding   UTF-8 äöüßÖÄÜ
 * @copyright  © 2011 Mario Schillermann (info@rockit-flash.com)
 * @license    GNU GPL v2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @uses       Zend_Controller_Action
 * @package    User
 * @subpackage Controller
 * @todo       Function editAction add filter request
 */
class User_Filter_Form
{
    /**
     * Filters and validators for create user form
     * 
     * @param  array $request
     * 
     * @return Zend_Filter_Input
     */
    static function create(array $request)
    {
        /** Set input filters and validators */ 
        $filters = array('*' => array('StringTrim','StripTags'));
        $validators = array(
            'role' => array(
                'allowEmpty' => FALSE,
                array('Int')
             ),
            'username' => array(
                'allowEmpty' => FALSE,
                array('stringLength', 3, 100)
            ),
            'firstname' => array(
                'allowEmpty' => FALSE,
                array('stringLength', 3, 100)
            ),
            'lastname' => array(
               'allowEmpty' => FALSE,
                array('stringLength', 3, 100)
            ),
            'password' => array(
                'allowEmpty' => FALSE,
                array('stringLength', 3, 100)
            )
        );

         return new Zend_Filter_Input($filters, $validators, $request);
     }
     
     /**
      * Filters and validators for edit user form
      *
      * @param  array $request
      *
      * @return Zend_Filter_Input
      */
     static function edit(array $request)
     {
         /** Set input filters and validators */
         $filters = array('*' => array('StringTrim','StripTags'));
         $validators = array(
             'role' => array(
                 'allowEmpty' => FALSE,
                 array('Int')
             ),
             'username' => array(
                 'allowEmpty' => FALSE,
                 array('stringLength', 3, 100)
             ),
             'firstname' => array(
                 'allowEmpty' => FALSE,
                 array('stringLength', 3, 100)
             ),
             'lastname' => array(
                 'allowEmpty' => FALSE,
                 array('stringLength', 3, 100)
             )
         );
         
         return new Zend_Filter_Input($filters, $validators, $request);
     }

     /**
      * Filters and validators for change password form
      *
      * @param  array $request
      *
      * @return Zend_Filter_Input
      */
     static function password(array $request)
     {
         /** Set input filters and validators */
         $filters = array('*' => array('StringTrim','StripTags'));
         $validators = array(
             'new' => array(
                 'allowEmpty' => FALSE,
                     array('stringLength', 8, 100)
             ),
             'repeat' => array(
                 'allowEmpty' => FALSE,
                 array('stringLength', 8, 100)
             )
         );
         
         return new Zend_Filter_Input($filters, $validators, $request);
     }
}